<template>
  <mu-flex
    class="photos-tools"
    v-if="photos && photos.length > 0"
    align-items="center"
  >
    <div v-for="(item, index) in photos" :key="index" class="item">
      <div
        @click="preview(item)"
        class="item-content"
        :style="{ backgroundImage: `url(${baseImgUrl + item})` }"
      ></div>
    </div>
    <div class="preview" v-show="previewOpen" @click="previewOpen = false">
      <img :src="baseImgUrl + previewImg" class="preview-img" />
    </div>
  </mu-flex>
</template>
<script>
// import imgtest from "../../../../../../assets/timg.jpeg";
export default {
  props: ["photos"],
  data() {
    return {
      previewImg: "",
      previewOpen: false,
      baseImgUrl: "http://image.xuexiwangzhe.com/",
    };
  },
  methods: {
    preview(value) {
      this.previewImg = value;
      this.previewOpen = true;
    },
  },
};
</script>

<style lang="less">
.photos-tools {
  width: 450px;
  .item {
    padding: 10px;
    width: 150px;
    height: 150px;
  }

  .item-content {
    cursor: pointer;
    width: 100%;
    height: 100%;
    background-size: cover;
  }

  .preview {
    position: fixed;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    top: 0;
    left: 0;
    background-color: rgba(0, 0, 0, 0.8);
    width: 100%;
    height: 100%;
  }

  .preview-img {
    height: 80%;
  }
}
</style>
